package edu.xidian.forum.common;

public enum Errors implements Error {
    /**
     * 成功
     */
    OK(200, "ok"),
    /**
     * 失败
     */
    FAILED(-1, "failed"),
    /**
     * 未登录，Token过期
     */
    UNAUTHORIZED(401, "no login"),
    /**
     * 权限不足
     */
    FORBIDDEN(403, "no permission"),
    /**
     * 参数校验错误
     */
    BAD_REQUEST(400, "bad request");

    private final int code;
    private final String message;

    Errors(int code, String message) {
        this.code = code;
        this.message = message;
    }

    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public String toString() {
        return "Errors{" +
                "code=" + code +
                ", message='" + message + '\'' +
                '}';
    }
}
